#!/bin/sh
# This regression test is a part of SIPp.
# Numbers: a leading 0 does not make an option octal, an empty string is
# not a number (for an option, a conversion or a line=), and an rtp_stream
# loop count must be a number.
. "`dirname "$0"`/../functions"; init

check_error() {
    what="$1"; expected="$2"; shift 2
    err=`sippfg -i 127.0.0.1 -p 24360 -m 1 -timeout 5 "$@" \
        127.0.0.1:24361 2>&1 >/dev/null`
    case $err in
        *"$expected"*) ;;
        *) rm -f f.csv; fail "$what: '$err', not '$expected'" ;;
    esac
}

rm -f uac_*_logs.log uac_*_errors.log
sippfg -sf uac.xml -i 127.0.0.1 -p 24360 -m 1 -timeout 5 -base_cseq 010 \
    127.0.0.1:24361 -trace_logs -trace_err >/dev/null 2>&1
status=$?
logs=`cat uac_*_logs.log 2>/dev/null`
errors=`cat uac_*_errors.log 2>/dev/null`
rm -f uac_*_logs.log uac_*_errors.log
if test $status -ne 0; then
    fail "the scenario failed with $status"
elif test "$logs" != "10 "; then
    fail "-base_cseq 010: logged '$logs', not '10 '"
fi
case $errors in
    *'Invalid double conversion from $empty to $d'*) ;;
    *) fail "an empty string converted to a double without a warning" ;;
esac

printf 'SEQUENTIAL\na;\n' >f.csv
check_error "line=\"\"" "Invalid line number generated: ''" -sf line.xml -inf f.csv
check_error "rtp_stream" 'rtp_stream loop count, "1x" is not a valid integer!' -sf rtp.xml
check_error "-l ''" '-l, "" is not a valid integer!' -sf uac.xml -l ''
rm -f f.csv
ok
